import React from 'react';
import ReactDom from 'react-dom'
import { AppContainer } from 'react-hot-loader';
import { Provider } from 'mobx-react';
// 引入Router Map
import RouterMap from './router/router_map';
import { createStore, createUserStore } from './stores/index'
import './static/css/common.css';

const stores = createStore();
const render = (Component) => {
  ReactDom.hydrate(
    <Provider {...stores} user={createUserStore()}>
      <AppContainer>
        <Component />
      </AppContainer>
    </Provider>,
    document.getElementById('app'),
  )
}
render(RouterMap)
if (module.hot) {
  module.hot.accept('./router/router_map.jsx', () => {
    const NextApp = require('./router/router_map.jsx').default
    render(NextApp)
  })
}
